#include <trax.hpp>
namespace AtomTrace{
    /**
    const PinHoleCamera LoadPinholeCameraFromGM(int address){

    } // LoadPinholeCameraFraomGM()
    **/

    PinHoleCamera::PinHoleCamera(int address)
    {
        LoadFromGM(address);
    }

    const PinHoleCamera & PinHoleCamera::LoadFromGM(int address)
    {
        focalDst = 1.0f; // always assume 1.0f focal dst if loading from memory
        //float tu = loadf(address, 15);   // <u, 0, 0>
        //float tv = loadf(address, 18+2); // <0, 0, v> [0, 0.5]
        //fovy = tv / 1.0f;
        Vector3 u(address+15);
        Vector3 v(address+18);
        fovy = v.Length() / focalDst;
        //fovy = 0.594f;
        imgWidth = GetXRes();
        imgHeight = GetYRes();

        position.LoadFromGM(address+0);
        dir.LoadFromGM(address+12);
        //lookat = position+gaze;
        up.LoadFromGM(address+9);

        UpdateCamParameter();
        return *this;
    }

}// namespace AtomTrace
